package com.superb.common.database.vo;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.superb.common.utils.StringUtils;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

/**
 * @Author: ajie
 * @CreateTime: 2024-05-07 16:29
 */
@Data
@Schema(description = "分页查询")
public class PageParams<T> {

    @Schema(description = "页码")
    private Long current;

    @Schema(description = "页大小")
    private Long size;

    @Schema(description = "查询参数")
    private T params;

    @Schema(hidden = true)
    public Page<T> getPage() {
        if (StringUtils.isNotBlank(current) && StringUtils.isNotBlank(size)) {
            return new Page<>(current, size);
        }
        return new Page<>(1, 10);
    }

    @Schema(hidden = true)
    public Page<T> getPage(Integer current, Integer size) {
        return new Page<>(current, size);
    }

}
